#coding=utf-8
from wechatpy import parse_message, create_reply
from wechatpy.replies import TextReply, ArticlesReply

import json,time, logging
from datetime import datetime
'''
    reply all msg except event
'''

logger = logging.getLogger('mylog')

def apply(msg):
    if msg.type == 'text':
        reply = text_reply(msg)
    elif msg.type == 'voice':
        reply = voice_reply(msg)
    return reply

def text_reply(msg):
    reply = None
    try:
        reply = create_reply('text reply', msg)
    except Exception as e:
        print 'error:', e
    return reply

def voice_reply(msg):
    reply = None
    try:
        reply = create_reply(str(msg), msg)
    except Exception as e:
        print 'error:', e
    return reply

